package com.coc.Observer.usrJdkObser;

import java.util.Observable;

public class CarColor extends Observable {

    // 监听的对象
    private String state ;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }


    // 对象 改变 通知观察者
    public void change(String state){
        System.out.println("观察对象改变状态 ： "+ this.state );

        this.state = state ;
        super.setChanged();   // 对象改变开关
        super.notifyObservers(this.state);

    }



}
